﻿using EFModel;
using IServices;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Y2.Dao;
using Y2.Filters;
using Y2.Models;

namespace Y2.Controllers
{
    //[LoginFilter]
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;

        private readonly Itype he;

        public HomeController(ILogger<HomeController> logger, Itype he)
        {
            _logger = logger;
            this.he = he;
        }

        public IActionResult Index()
        {
            ViewBag.u_id = HttpContext.Session.GetString("id");
            ViewBag.name = HttpContext.Session.GetString("name");
            ViewBag.zhiwu = HttpContext.Session.GetString("zhiwu");
            return View();
        }
        //递归查询所有权限
        public async Task<string> dg()
        {
            return await he.dg();
        }
        //递归查询当前id所有权限
        public async Task<string> dgto(int id)
        {
            return await he.dgto(id);
        }
        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]

        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
